package com.xiaoyg.string;

import java.util.Arrays;

public class isPalindrome {

    public static void main(String[] args) {
//        String str = "A man, a plan, a canal: Panama";
//
//        System.out.println("xx"+isPalindrome(str));

        int x = 1534236469;
        System.out.println(Integer.MIN_VALUE/10);
        System.out.println(Integer.MAX_VALUE/10);
        int result = reverse(x);

        System.out.println(result);
    }

    public static boolean isPalindrome(String s) {
        String s1 = s.toUpperCase();
        char[] chars = s1.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0;i<chars.length;i++){
            if (Character.isDigit(chars[i]) || Character.isUpperCase(chars[i])){
                sb.append(chars[i]+"");
            }
        }
        String A = sb.toString();
        String B = sb.reverse().toString();
        return A.equals(B);
    }


    public static int reverse(int x) {
        boolean flag = false;
        if(x < 0){
            flag = true;
            x = Math.abs(x);
        }

        int num = x;
        StringBuilder cur = new StringBuilder();

        while(num != 0){
            cur = cur.append(num % 10);
            num = num / 10;
        }


        return Integer.valueOf(cur.toString());
    }

}
